package com.usf.jprovider.tools;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public final class DAOTools {
	
	public static Connection createConnection(String driver,
			String url,String user,String password) throws ClassNotFoundException, SQLException {
			Class.forName(driver);
			return DriverManager.getConnection(url, user, password);  
	}	
	
	public static String executeSelectQuery(Connection connection, String query) throws SQLException {
		Statement stat = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
		ResultSet rs = stat.executeQuery(query); 
		rs.next(); 
		return rs.getString(1);
	}	
}
